<?php 

	 function sanitizeID($id){
		$trace=debug_backtrace();
		$caller=array_shift($trace);
		
		$id = (int) $id;
		if (! is_numeric($id)) return 'Error: ID not a number in $caller' ;
		if ( (!is_int($id)) || ($id<=0)) return 'Error: ID should be a normal number in $caller';
		
		return $id;
	}
	
	function removeVote($user, $petition){
		return get_instance()->db->query('DELETE FROM petition_vote WHERE user_id= ? AND petition_id= ?', 
			array($user, $petition));		
	}
	
	function addVote($user, $petition){
		return get_instance()->db->query('INSERT INTO petition_vote (user_id, petition_id, vote_time) VALUES (? , ?, DEFAULT)', 
			array($user, $petition));
	}